@Html.Partial("Section\\_Summary")
@{
	IDocument containingAssembly = Model.Get<IDocument>(CodeAnalysisKeys.ContainingAssembly);
	IDocument containingNamespace = Model.Get<IDocument>(CodeAnalysisKeys.ContainingNamespace);
	IReadOnlyList<IDocument> allInterfaces = Model.List<IDocument>(CodeAnalysisKeys.AllInterfaces);
	IReadOnlyList<IDocument> baseTypes = Model.List<IDocument>(CodeAnalysisKeys.BaseTypes);
	IReadOnlyList<IDocument> derivedTypes = Model.List<IDocument>(CodeAnalysisKeys.DerivedTypes);
	IReadOnlyList<IDocument> implementingTypes = Model.List<IDocument>(CodeAnalysisKeys.ImplementingTypes);
	if(containingAssembly != null
		|| containingNamespace != null
		|| (allInterfaces != null && allInterfaces.Count > 0)
		|| (baseTypes != null && baseTypes.Count > 0)
		|| (derivedTypes != null && derivedTypes.Count > 0)
		|| (implementingTypes != null && implementingTypes.Count > 0))
	{
		<div class="panel panel-default">
  			<div class="panel-body">
				<div class="row">
					<div class="col-md-6">
						<dl class="dl-horizontal">		
							@if(containingAssembly != null)
							{	
								<dt>Assembly</dt>
								<dd>@Context.GetTypeLink(containingAssembly)</dd>
							}

							@if(containingNamespace != null)
							{	
								<dt>Namespace</dt>
								<dd>@Context.GetTypeLink(containingNamespace)</dd>
							}
											
							@if(allInterfaces != null && allInterfaces.Count > 0)
							{
								<dt>Interfaces</dt>
								<dd>
									<ul class="list-unstyled">
										@foreach(IDocument interfaceDocument in allInterfaces)
										{
											<li>@Context.GetTypeLink(interfaceDocument)</li>								
										}
									</ul>
								</dd>
							}
							
							@if(baseTypes != null && baseTypes.Count > 0)
							{
								<dt>Base Types</dt>
								<dd>
									<ul class="list-unstyled">										
										@foreach(IDocument baseType in baseTypes.Reverse())
										{
											<li>@Context.GetTypeLink(baseType)</li>								
										}
									</ul>
								</dd>				
							}
							
							@if(derivedTypes != null && derivedTypes.Count > 0)
							{
								<dt>Derived Types</dt>
								<dd>
									<ul class="list-unstyled">
										@foreach(IDocument derivedType in derivedTypes)
										{
											<li>@Context.GetTypeLink(derivedType)</li>								
										}
									</ul>
								</dd>			
							}
							
							@if(implementingTypes != null && implementingTypes.Count > 0)
							{
								<dt>Implementing Types</dt>
								<dd>
									<ul class="list-unstyled">
										@foreach(IDocument implementingType in implementingTypes)
										{
											<li>@Context.GetTypeLink(implementingType)</li>								
										}
									</ul>
								</dd>				
							}
						</dl>
					</div>		
					<div class="col-md-6">
						@{
							System.Text.StringBuilder hierarchy = new System.Text.StringBuilder();
							hierarchy.AppendLine("graph BT");
							if(baseTypes != null && baseTypes.Count > 0)
							{
								for(int b = 0 ; b < baseTypes.Count ; b++)
								{
									hierarchy.AppendLine($"\t{(b == 0 ? "Type" : "Base" + (b - 1))}-->Base{b}[\"{System.Net.WebUtility.HtmlEncode(baseTypes[b].String(CodeAnalysisKeys.DisplayName))}\"]");
									if(baseTypes[b].ContainsKey(Keys.WritePath))
									{
										hierarchy.AppendLine($"\tclick Base{b} \"{(Context.GetLink(baseTypes[b].FilePath("WritePath")))}\"");
									}
								}
							}
							if(allInterfaces != null && allInterfaces.Count > 0)
							{
								for(int c = 0 ; c < allInterfaces.Count ; c++)
								{
									hierarchy.AppendLine($"\tType-.->Interface{c}[\"{System.Net.WebUtility.HtmlEncode(allInterfaces[c].String(CodeAnalysisKeys.DisplayName))}\"]");			
									if(allInterfaces[c].ContainsKey(Keys.WritePath))
									{
										hierarchy.AppendLine($"\tclick Interface{c} \"{(Context.GetLink(allInterfaces[c].FilePath("WritePath")))}\"");
									}				
								}
							}
							hierarchy.AppendLine($"\tType[\"{System.Net.WebUtility.HtmlEncode(Model.String(CodeAnalysisKeys.DisplayName))}\"]");		
							hierarchy.AppendLine("class Type type-node");				
							if(derivedTypes != null && derivedTypes.Count > 0)
							{
								for(int c = 0 ; c < derivedTypes.Count ; c++)
								{
									hierarchy.AppendLine($"\tDerived{c}[\"{System.Net.WebUtility.HtmlEncode(derivedTypes[c].String(CodeAnalysisKeys.DisplayName))}\"]-->Type");							
									if(derivedTypes[c].ContainsKey(Keys.WritePath))
									{
										hierarchy.AppendLine($"\tclick Derived{c} \"{(Context.GetLink(derivedTypes[c].FilePath("WritePath")))}\"");
									}			
								}		
							}						
							if(implementingTypes != null && implementingTypes.Count > 0)
							{
								for(int c = 0 ; c < implementingTypes.Count ; c++)
								{
									hierarchy.AppendLine($"\tImplementing{c}[\"{System.Net.WebUtility.HtmlEncode(implementingTypes[c].String(CodeAnalysisKeys.DisplayName))}\"]-.->Type");			
									if(implementingTypes[c].ContainsKey(Keys.WritePath))
									{
										hierarchy.AppendLine($"\tclick Implementing{c} \"{(Context.GetLink(implementingTypes[c].FilePath("WritePath")))}\"");
									}							
								}
							}
						}
						<div class="mermaid">
							@Html.Raw(hierarchy.ToString())
						</div>
					</div>
				</div>
  			</div>
		</div>
	}
}

@Html.Partial("Section\\_Syntax")
@Html.Partial("Section\\_Examples")
@Html.Partial("Section\\_Remarks")
@Html.Partial("Section\\_Attributes")
@Html.Partial("Section\\_TypeParameters")
@Html.Partial("Section\\_Constructors")
@Html.Partial("Section\\_Events")
@Html.Partial("Section\\_Fields")
@Html.Partial("Section\\_Properties")
@Html.Partial("Section\\_Methods")
@Html.Partial("Section\\_Operators")
@Html.Partial("Section\\_ExtensionMethods")
@Html.Partial("Section\\_SeeAlso")